#include "Applejack/world.hpp"
#include "Applejack/fixture.hpp"

using namespace Shiny;
using namespace Applejack;

void World::CollisionManager::BeginContact(b2Contact* contact)
{
  Fixture* fixtureA = Fixture::GetFixture(contact->GetFixtureA());
  Fixture* fixtureB = Fixture::GetFixture(contact->GetFixtureB());

  if (fixtureA) fixtureA->ContactBegin.Emit(contact);
  if (fixtureB) fixtureB->ContactBegin.Emit(contact);
}

void World::CollisionManager::EndContact(b2Contact* contact)
{
  Fixture* fixtureA = Fixture::GetFixture(contact->GetFixtureA());
  Fixture* fixtureB = Fixture::GetFixture(contact->GetFixtureB());

  if (fixtureA) fixtureA->ContactEnd.Emit(contact);
  if (fixtureB) fixtureB->ContactEnd.Emit(contact);
}
